﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _44 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ParentChildTasks",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    Title = table.Column<string>(type: "longtext", nullable: true, comment: "标题")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TaskIntroduction = table.Column<string>(type: "longtext", nullable: true, comment: "任务简介")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClassId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "班级id", collation: "ascii_general_ci"),
                    ClockInDays = table.Column<int>(type: "int", nullable: false, comment: "打卡天数"),
                    StartDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "开始时间"),
                    EndDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "结束时间"),
                    DailyClockInDeadline = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "每日打卡截止时间"),
                    State = table.Column<int>(type: "int", nullable: false, comment: "任务状态"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ParentChildTasks", x => x.Id);
                },
                comment: "亲子任务")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ParentChildTasksImage",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    FiledId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "文件Id", collation: "ascii_general_ci"),
                    FileName = table.Column<string>(type: "longtext", nullable: false, comment: "文件名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileSize = table.Column<string>(type: "longtext", nullable: false, comment: "文件大小")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ParentChildTasksId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "班级动态Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ParentChildTasksImage", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ParentChildTasksImage_ParentChildTasks_ParentChildTasksId",
                        column: x => x.ParentChildTasksId,
                        principalTable: "ParentChildTasks",
                        principalColumn: "Id");
                },
                comment: "亲子任务图片表")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ParentChildTasksRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    Content = table.Column<string>(type: "longtext", nullable: true, comment: "记录内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreateUserName = table.Column<string>(type: "longtext", nullable: true, comment: "发布人姓名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Relationship = table.Column<int>(type: "int", nullable: true, comment: "家属关系"),
                    RelationshipChildrenId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "关联幼儿Id", collation: "ascii_general_ci"),
                    ParentChildTasksId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "亲子任务Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ParentChildTasksRecord", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ParentChildTasksRecord_ParentChildTasks_ParentChildTasksId",
                        column: x => x.ParentChildTasksId,
                        principalTable: "ParentChildTasks",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "亲子任务完成记录")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_ParentChildTasksImage_ParentChildTasksId",
                table: "ParentChildTasksImage",
                column: "ParentChildTasksId");

            migrationBuilder.CreateIndex(
                name: "IX_ParentChildTasksRecord_ParentChildTasksId",
                table: "ParentChildTasksRecord",
                column: "ParentChildTasksId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ParentChildTasksImage");

            migrationBuilder.DropTable(
                name: "ParentChildTasksRecord");

            migrationBuilder.DropTable(
                name: "ParentChildTasks");
        }
    }
}
